<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{/fragment/OrderHeader :: OrderHeader}"/>
<body class="cbp-spmenu-push">
<section th:replace="~{/fragment/SectionButton :: SectionButton}"/>
<nav th:replace="~{fragment/nav :: nav}"/>
<div th:replace="~{/fragment/banner :: banner}"/>
<!--<div/>-->
<div class="content_section">
    <div class="hm_main_content content clearfix row_spacer2">
        <div class="entry-content">
            <div class="shopping-commerce">
                <table class="shop_table shop_table_responsive cart check_out_table">
                    <thead>
                    <tr>
                        <th class="product-thumbnail" th:text="房型">&nbsp;</th>
                        <th class="product-name" th:text="酒店名">Product</th>
                        <th class="product-quantity" th:text="房间数">Quantity</th>
                        <th class="product-subtotal" th:text="入住时间">Total</th>
                        <th class="product-subtotal" th:text="退房时间">Total</th>
                        <th class="product-subtotal" th:text="单价">Total</th>
                        <th class="product-subtotal" th:text="真实姓名">Total</th>
                        <th class="product-subtotal" th:text="手机号码">Total</th>
                    </tr>
                    </thead>

                    <tbody>
                    <tr class="cart_item">
                        <td class="product-thumbnail">
                            <span id="rtypeId" name="rtypeId" th:text="${roomTypeName}"></span>
                        </td>
                        <td class="product-id">
                            <a href="#" id="hotelName" th:text="${hotelName}"> </a>
                        </td>
                        <td class="product-quantity">
                            <div class="quantity buttons_added clearfix">
                                <div class="quantity_controll_con">
                                    <input type="button" class="quantity_controll minus" value="-">
                                    <input type="number" id="roomCount" step="1" min="0" max="10" value="1" class="input-text"
                                           size="4"/>
                                    <input type="button" class="quantity_controll plus" value="+">
                                </div>
                            </div>
                        </td>
                        <td class="product-price">
                            <span id="inTime" th:text="${CheckIntime}">[[${CheckIntime}]]</span>
                        </td>
                        <td class="product-price">
                            <span id="outTime" th:text="${CheckOuttime}">[[${CheckOuttime}]]</span>
                        </td>
                        <td class="product-subtotal">
                            <span class="amount" id="unitPrice" th:text="${roomPrice}"></span><span>元</span>
                        </td>
                        <td class="product-price">
                            <input type="text" th:name="Rname" id="Rname"/>
                        </td>
                        <td class="product-price">
                            <input type="text" th:name="phone" id="phone"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div class="cart-collaterals">
                    <div class="cart_totals ">
                        <h2>订单总计</h2>
                        <table class="shop_table shop_table_responsive">
                            <tr class="order-total">
                                <th>总计</th>
                                <td data-title="Total">
                                    <span>￥</span>
                                    <strong><span id="price" class="amount"></span></strong>
                                </td>
                            </tr>
                        </table>
                        <table>
                            <tr>
                                <td>
                                    <div class="commerce-proceed-to-checkout">
                                        <input type="button" class="checkout-button button " id="toPayment" value="付款">
                                    </div>
                                </td>
                                <td>
                                    <div class="commerce-proceed-to-checkout">
                                        <a th:href="@{/roominfo(id=${roomId})}" class="checkout-button button"> 取消订单</a>
                                    </div>
                                </td>
                            </tr>
                        </table>

                    </div>
                </div>
                <!-- End cart-collaterals -->

            </div>
            <!-- End shopping-commerce -->

        </div>
    </div>
</div>
<div th:replace="~{/fragment/footer :: footer}"/>
<script type="text/javascript" th:inline="javascript">

    $(function () {
        $("#price").text($("#unitPrice").text());
    })

    $(document).ready(function () {
        $("#roomCount").on('change',function () {
            var  roomCount=$("#roomCount").val();
            var dataDiffrent=[[${dataDiffient}]];
            var unitPrice=$("#unitPrice").text();
            var  priceCount=roomCount*unitPrice*dataDiffrent;
            $("#price").text(priceCount)
        })
    });


    $("#toPayment").click(
        function payment() {
            var roomTypeId=[[${roomId}]];
            var CheckOutTime=$("#inTime").text();
            var CheckIntTime=$("#outTime").text();
            var Rname=$("#Rname").val();
            var Phone=$("#phone").val();
            var RoomCount=$("#roomCount").val();
            var PriceCount=$("#price").text();
            $.post("/toPayment"
                ,
                {
                    rtypeId:roomTypeId,
                    inTime:CheckIntTime,
                    outTime:CheckOutTime,
                    rname:Rname,
                    phone:Phone,
                    roomCount:RoomCount,
                    price:PriceCount
                }
                ,function (data) {
                 var ordernum=data.ordernum;
                 var  Oprice =data.orderPrice;
                 location.href="/toPaymenttransfer?ordernum="+ordernum+"&price="+Oprice ;
                }
            )

        }
    )

</script>
</body>
</html>